define(function(require, exports){
    var T = require('T');
    var $ = require('$');
    var ui = require('ui');

    /*$(".msgbox").addClass("active");
    $(".open").click(function(){
        ui.msgbox();
    });*/

    function submitStatus(v , reset){

        var submit = v.find("button[type='submit']");//

        if(reset === true){
            submit.html("提交").removeClass("disabled");
        }else
            submit.html( submit.data("loading-text")).addClass("disabled");
    }

    $(".iframe-body").on("click","*[type='submit']",function(){
        var form = $(this).parents("form");
        submitStatus(form);

        $.ajax({
            url :form.attr("action"),
            data:form.serialize(),
            type:form.attr("method") || "POST",
            dataType : "json",
            success:function(d){
                if(d.status == "0"){
                    submitStatus(form , true);
                    ui.notify("保存成功！","success");
                }else{
                    submitStatus(form , true);
                    ui.notify("远端保存失败！","error");
                }

            },
            error : function(a,b,c){
                submitStatus(form , true);
                ui.notify("返回数据错误！","error");

            }

        });
        return false;
    })
})